import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import sessionsService from '/@/api/cn/core/sign/sessionsService'

import type { Sessions } from '/@/model/cn/core/sign/eo/Sessions'
import type { SessionsQO } from '/@/model/cn/core/sign/qo/SessionsQO'
import type { SessionsVO } from '/@/model/cn/core/sign/vo/SessionsVO'

interface SessionsState {
}

export const useSessionsStore = defineStore({
  id: 'sessions',
  state: (): SessionsState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.save(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.saveBatch(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.update(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.updateBatch(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.remove(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<Sessions>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.removeBatch(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<SessionsQO>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.count(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<SessionsQO>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.pk(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<SessionsQO>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.query(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<SessionsQO>): Promise<Res<Sessions>> {
      return new Promise<Res<Sessions>>((resolve, reject) => {
        sessionsService.paging(param).then((res: AxiosResponse<Res<Sessions>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<SessionsQO>): Promise<Res<SessionsVO>> {
      return new Promise<Res<SessionsVO>>((resolve, reject) => {
        sessionsService.countVo(param).then((res: AxiosResponse<Res<SessionsVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<SessionsQO>): Promise<Res<SessionsVO>> {
      return new Promise<Res<SessionsVO>>((resolve, reject) => {
        sessionsService.pkVo(param).then((res: AxiosResponse<Res<SessionsVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<SessionsQO>): Promise<Res<SessionsVO>> {
      return new Promise<Res<SessionsVO>>((resolve, reject) => {
        sessionsService.queryVo(param).then((res: AxiosResponse<Res<SessionsVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<SessionsQO>): Promise<Res<SessionsVO>> {
      return new Promise<Res<SessionsVO>>((resolve, reject) => {
        sessionsService.pagingVo(param).then((res: AxiosResponse<Res<SessionsVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useSessionsStoreWithout() {
  return useSessionsStore(store)
}
